<div class="container">


  <div class="row">
    <div class="col-md-12">
       <nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">项目集</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
       
      <form class="navbar-form navbar-left" action='{:url("index/index")}' method="get">
        <div class="form-group">
          关键字：<input type="text" class="input-medium search-query" name="kwd" value="{$search.kwd}" />
        </div>
        <button type="submit" class="btn btn-default">搜索</button>
           &ensp;共计<strong>&nbsp;{$total}&nbsp;</strong>条记录
      </form>
       
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

    </div>
  </div>
  <div class="row">
  <div class="col-md-12"> 
    <div class="pull-right"><!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-small add_item" >
 +添加
</button></div>

    <table class="table table-hover table-bordered table-condensed">
      <thead>
        <tr>
          <th>ID</th>
           
          <th>项目集</th>
          <th>描述</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        {volist name="ls" id="vo"}
        <tr>
          <td>{$vo.item_id}</td>
           
          <td>{$vo.item_name}</td>
          <td>{$vo.item_desc}</td>
          <td>
             <a  href="javascript:;" class="de fault-primary edit_item" rel="{$vo.item_id}" > <span class="glyphicon glyphicon-edit"></span>
</a>
 &ensp;
             <a  href="{:url('index/itemdel',['item_id'=>$vo.item_id])}" class="de fault-primary" onclick="return confirm('确认删除?')" ><span class="glyphicon glyphicon-trash"></span></a>
             &ensp;

                 <a  href="javascript:;" class="exportimgs" rel="{$vo.item_id}"  title="导出"> <span class="glyphicon glyphicon-export"></span>
</a>



          </td>
        </tr>
        {/volist}
      </tbody>
    </table>



  </div>
  <div class="row text-center">{$page|raw}</div>
</div>
</div>

<div id="app">
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="myModalLabel">Modal title</h4>
          </div>
          <div class="modal-body">
             <form action="/index/item_edit" method="POST" role="form">
              <legend>项目集</legend>
             
              <div class="form-group">
                <label for="">名称</label>
                <input type="text"  name="item_name" class="form-control" id="" placeholder="请输入用户名" v-model="item_info.item_name">
              </div>
              

               <div class="form-group">
                <label for="">描述</label>
                <input type="text"  name="item_desc" class="form-control" id="" placeholder="请输入描述" v-model="item_info.item_desc">
              </div>
              
             
              
              <input type="hidden" name="item_id"  v-model="item_info.item_id" />
              <button type="submit" class="btn btn-primary">保存</button>
             </form>
          </div>
          
        </div>
      </div>
    </div>
</div>
 

  <!-- export modal -->
    <div class="modal fade" id="modal-export">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">导出数据</h4>
                </div>
                <div class="modal-body">
                        <form action="" method="POST" role="form" id="export_form">
                        
                        
                            <div class="form-group">
                                <label for="">训练集占比</label>
                                <input type="text" class="form-control" name="train"  value="9" >
                            </div>
                        <div class="form-group">
                                <label for="">测试集占比</label>
                                <input type="text" class="form-control" name="test" value="0.5">
                            </div>
                         <div class="form-group">
                                <label for="">验证集占比</label>
                                <input type="text" class="form-control" name="valid" value="0.5">
                            </div>               
                            <input type="hidden" name="item_id" value="" />
                            <button type="button" class="btn btn-primary btn_export">提交</button>
                        </form>
                </div>
                
            </div>
        </div>
    </div>
    <!-- export modal -->
<script type="text/javascript">
   
var app = new Vue({
  el: '#app',
  data: {
    item_info:{
       
    }
  }
})



 $('.exportimgs').click(function(event) {
          let _item_id = $(this).attr("rel");
          $("#export_form").find("input[name='item_id']").val(_item_id);
          $("#modal-export").modal("show");
          
    });


    $("#modal-export .btn_export").click(function(event) {    

        let _data = $("#export_form").serializeArray();
        let dataObj = {};
        $(_data).each(function(i, field){
          dataObj[field.name] = field.value;
        });

        let _item_id=  dataObj.item_id;
         
        if(!_item_id){
            $.ThinkBox.error('请选择项目集');
            return false;
        }

        $.getJSON("/index/export",_data,function(data){
            $("#modal-export").modal("hide");
            $.ThinkBox.success(data.msg);
       })



    });


$(".edit_item").click(function(event) {
   let _id  = $(this).attr("rel");
   $.get('/index/item_edit',{item_id:_id},function(data) {
      $('#myModal').modal('show') ;
      app.item_info=  data.item_info; 
   });
});

$(".add_item").click(function(event) {
    app.item_info={};
    $('#myModal').modal('show') ;
});

if(location.search.indexOf("add=1")>-1){
  $(".add_item").trigger('click');
}
</script>